package com.hmall.common.dto;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;


/**
 * 文档类
 *
 * @author zhang
 * @date 2022/06/12
 */
@Data
@NoArgsConstructor
public class ItemDoc {
    /**
     * 商品ID
     */
    private Long id;
    /**
     * 商品名称
     */
    private String name;
    /**
     * 价格（分）
     */
    private Long price;
    /**
     * 商品图片
     */
    private String image;
    /**
     * 分类名称
     */
    private String category;
    /**
     * 品牌名称
     */
    private String brand;
    /**
     * 销量
     */
    private Integer sold;
    /**
     * 评论数
     */
    private Integer commentCount;
    /**
     * 自动补全
     */
    private List<String> suggestion;
    /**
     * 是否是广告
     */
    private Boolean isAD;

    public ItemDoc(Item item) {
        this.id = item.getId();
        this.name = item.getName();
        this.price = item.getPrice();
        this.image = item.getImage();
        this.category = item.getCategory();
        this.brand = item.getBrand();
        this.sold = item.getSold();
        this.commentCount = item.getCommentCount();
        this.suggestion = Arrays.asList(this.brand, this.category);
        this.isAD = item.getIsAD();
    }
}
